package com.thesis.manage.controller;

import com.thesis.manage.common.controller.AbstractController;
import com.thesis.manage.domain.Time;
import com.thesis.manage.service.TimeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author php
 * @date 2018/2/27
 */
@RestController
@RequestMapping("/time")
public class TimeController extends AbstractController {
    @Resource
    private TimeService timeService;

    @PostMapping("/save")
    public Map<String, Object> save(@RequestBody Time time) {
        return buildMessage(() -> {
            timeService.save(time);
            return null;
        });
    }

    @GetMapping("/info")
    public Map<String, Object> info() {
        return buildMessage(() -> timeService.info());
    }

    @DeleteMapping("/{type}/close")
    public Map<String,Object> info(@PathVariable Integer type){
        return buildMessage(() -> {
            timeService.close(type);
            return null;
        });
    }
}
